package org.appfuse.dao.hibernate;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.appfuse.dao.ZnodeTreeDAO;
import org.appfuse.model.ZnodeTree;
import org.hibernate.Query;

/**
 * Data access object (DAO) for domain model class ZNodeTree.
 * 
 * @see org.appfuse.dao.ZNodeTree
 * @author MyEclipse Persistence Tools
 */

public class ZnodeTreeDAOHibernate extends BaseDaoHibernate implements ZnodeTreeDAO {
	private static final Log log = LogFactory.getLog(ZnodeTreeDAO.class);

	// property constants
	public static final String PARENT_ID = "parentId";

	public static final String FULL_NAME = "fullName";

	public static final String NAME = "name";

	public static final String PASSWORD = "password";

	public static final String IS_REGISTED = "isRegisted";

	public static final String ADMIN_NAME = "adminName";

	public static final String CONTACT_PHONE = "contactPhone";

	public static final String DESCRIPTION = "description";

	public static final String PHYSICAL_NODE_ID = "physicalNodeId";

	public static final String COMPUTER_ID = "computerId";

	public void save(ZnodeTree transientInstance) {
		log.debug("saving ZNodeTree instance");
		try {
			getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(ZnodeTree persistentInstance) {
		log.debug("deleting ZNodeTree instance");
		try {
			getSession().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public ZnodeTree findById(java.lang.String id) {
		log.debug("getting ZNodeTree instance with id: " + id);
		try {
			ZnodeTree instance = (ZnodeTree) getSession().get(
					"org.appfuse.dao.ZnodeTree", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public List findAll() {

		log.debug("finding all ZnodeTree instance");
		try {
			String queryString = "from ZnodeTree as model ";
			Query queryObject = getSession().createQuery(queryString);
			return queryObject.list();
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}

	}
}